package lib.bone.access.module.post.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.hibernate.Hibernate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;
import java.util.Objects;

/**
 * @Author : kindear
 * @Date : 2021-12-13
 * 东北石油大学岗位表
 */
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
@Table(name = "nepu_post")
@EntityListeners(AuditingEntityListener.class)
@ApiModel(value = "岗位信息")
@GenericGenerator(name = "jpa-uuid", strategy = "uuid")
public class NepuPost {

    @Id
    @GeneratedValue(generator = "jpa-uuid")
    @ApiModelProperty(value = "岗位ID",name = "id")
    String id;

    @ApiModelProperty(value = "岗位类型",notes = "岗位类型：教师岗（教学型、教学研究型和研究型），其他专业技术岗、管理岗、职员岗、工勤岗")
    @Column(name = "post_type")
    String postType;

    @ApiModelProperty(value = "岗位级别",notes = "")
    @Column(name = "post_level")
    String postLevel;

    @ApiModelProperty(value = "岗位等级",notes = "岗位等级：二、三、四等，缺省值设置为*（适配工勤）")
    @Column(name = "post_grade")
    String postGrade;

    @ApiModelProperty(value = "岗位津贴系数",notes = "")
    @Column(name = "standard",scale = 2)
    Double standard;

    /**
     * 岗位需要的教学工作量
     */
    @ApiModelProperty(value = "教学工作量",notes = "限制教师岗")
    @Column(name = "teach_workload",scale = 2)
    Double teachWorkload;

    /**
     * 岗位需要的科研工作量
     */

    @ApiModelProperty(value = "科研工作量",notes = "限制教师岗")
    @Column(name = "research_workload",scale = 2)
    Double researchWorkload;

    @ApiModelProperty(value = "岗位备注")
    @Column(name = "remark",length = 1024)
    String remark;

    @CreatedDate
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @ApiModelProperty(value = "记录创建时间",name = "createdTime")
    @Column(name = "created_time")
    private Date createdTime;
    @LastModifiedDate
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @ApiModelProperty(value = "记录更新时间",name = "updatedTime")
    @Column(name = "updated_time")
    private Date updatedTime;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
        NepuPost nepuPost = (NepuPost) o;
        return id != null && Objects.equals(id, nepuPost.id);
    }

    @Override
    public int hashCode() {
        return getClass().hashCode();
    }
}
